#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(){
	int a=0,b=1,c=0;
	char in,x[2],y[99];
	printf("v0.2 项目完成基础功能\n");
	printf("命令模式:wc.exe [参数] [文件名]\n");
	printf("请输入参数（-a为字符数，-b为单词数，-c为句子数）和文件名\n");
    printf("wc.exe ");
	scanf("%s %s",x,y);
	FILE*ins=fopen(y,"r");
    if(ins==NULL){
        printf("未找到文件\n");
    }
	while((in=getc(ins))!=EOF){
		a++;
        if((in=='.')||(in=='!')||(in=='?')){
				a++;
				c++;
		}
		  else if(in==' '){
                b++;
				a--;
		}
          else if((in==',')||(in==':')||(in==';')){
			    a++;
		}		
	}
	if(x[1]=='a'){
		printf("字符数=%d\n",a);
	}
	if(x[1]=='b'){
		printf("单词数=%d\n",b);
	}
	if(x[1]=='c'){
		printf("句子数=%d\n",c);
	}
	fclose(ins);
    system("pause");
    return 0;
}